package easy

func FindMaxAverage(nums []int, k int) float64 {
	n := len(nums)
	sum := 0
	for i := 0; i < k; i++ {
		sum += nums[i]
	}
	maxSum := sum
	for j := k; j < n; j++ {
		sum = sum - nums[j-k] + nums[j]
		maxSum = max(maxSum, sum)
	}
	return float64(maxSum) / float64(k)
}
